<?php
/**
 * Created by PhpStorm.
 * User: saive
 * Date: 16-4-28
 * Time: 下午10:59
 *
 * 虚拟主机管理
 *
 */
include_once "inc/template.php";
include_once "inc/functions.php";
include_once "inc/files.php";

_dump($virtuals);

?>

<!DOCTYPE html>
<html lang="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Web版本虚拟主机管理器</title>
<link rel="stylesheet" href="css/style.default.css" type="text/css"/>
<link rel="stylesheet" href="css/bootstrap.css"/>
<script type="text/javascript" src="js/plugins/jquery-1.7.min.js"></script>
</head>

<body>

<div class="row">
    <div class="col-md-12">

        <div class="col-md-2"></div>

        <div class="col-md-8">

            <table class="table table-striped">
                <thread>
                    <tr>
                        <th>Alias</th>
                        <th>Domain</th>
                        <th>FileName</th>
                        <th>Workspace</th>
                        <th>State</th>
                    </tr>
                </thread>
                <tbody>
                <?php foreach ($virtuals as $virtual) { ?>
                    <tr>
                        <td><?php echo $virtual; ?></td>
                        <td><?php echo $virtual; ?></td>
                        <td><?php echo $virtual; ?></td>
                        <td><?php echo $virtual; ?></td>
                        <td>
                            <div class="btn-group">
                                <button class="btn btn-default btn-sm" data-class="check_conf" data-name="<?php echo $virtual; ?>">检测</button>
                            </div>
                        </td>
                    </tr>
                <?php } ?>
                <tr>
                    <td>
                        <input type="text" placeholder="虚拟机备注" value="" id="alias">
                    </td>
                    <td>
                        <input type="text" placeholder="虚拟机域名" value="" id="domain"/>
                    </td>
                    <td>
                        <input type="text" placeholder="***.conf" value="" id="filename"/>
                    </td>
                    <td>
                        <input type="text" placeholder="/workspace/" value="" id="workspace"/>
                    </td>
                    <td>
                        <button class="btn btn-primary" id="addConf">添加</button>
                    </td>
                </tr>
                </tbody>
            </table>

        </div>

        <div class="col-md-2"></div>
    </div>
</div>
<script>
    $(function () {
        $('button[data-class="check_conf"]').click(function(){
            var name = $(this).attr('data-name');
            $.post("inc/ajaxCheckConf.php",{name:name},function(callback){

            

            },'json');
        });

        /**
         * 添加配置
         */
        $('#addConf').click(function () {
            var alias = $("#alias").val();
            var domain = $("#domain").val();
            var filename = $("#filename").val();
            var workspace = $("#workspace").val();
            $.post("inc/ajaxAddConf.php", {alias: alias,domain: domain,workspace: workspace,filename: filename}, function (callback) {
                console.log(callback);
                return false;
                if (callback.status == 1) {
                    window.location.reload();
                } else {
                    alert(callback.msg);
                }
            }, 'json');

        });
    });
</script>
</body>
</html>




